import java.util.List;
import java.util.ArrayList;
import java.io.InputStream;
import org.apache.ibatis.session.*;

public class TestATM{
	public static void main(String args[]) throws Exception{
		new DateBaseUtil();

		// UserDao userDao = new UserDao();

		// User user = new User();
		// user.username = "tom";
		// user.cardNum = "62220xxxxx";
		// user.balance = 10;

		// int rows = userDao.add(user);
		// if (rows < 1) {
		// 	System.out.println("insert user failed");
		// }

		// DetailDao detailDao = new DetailDao();

		// Detail detail = new Detail();
		// detail.userId = 1;
		// detail.amount = 10;
		// detail.descMsg = "百度外卖汉堡包";

		// int rows = detailDao.add(detail);
		// if (rows < 1) {
		// 	System.out.println("insert user failed");
		// }

		// UserDao userDao = new UserDao();
		// int rows = userDao.modifyBalance(120, 2);
		// if (rows != 1) {
		// 	System.out.println("update user balance failed");
		// }

		// UserDao userDao = new UserDao();
		// User user = userDao.queryUser("6220xxxx1");
		// System.out.println(user);

		 // DetailDao detailDao = new DetailDao();
		 // List<Detail> list = detailDao.query("6220xxxx1");
		 // for (Detail d : list) {
		 // 	System.out.println(d);
		 // }


		
		

		//userService.openAccount("liyanhong6", "62203359155560", 500);
		//userService.deposit("62203359168888", 10);
		

		// new Thread(new Runnable() {
		// 	public void run() {
		// 		UserServiceImpl userService = new UserServiceImpl();
		// 		userService.setUserDao(new UserDaoImpl());
		// 		userService.setDetailDao(new DetailDaoImpl());
		// 		userService.transfer("62203359155560", "62203359168888", 158);

		// 	}
		// }, "丈夫").start();

		// new Thread(new Runnable() {
		// 	public void run() {
		// 		UserServiceImpl userService = new UserServiceImpl();
		// 		userService.setUserDao(new UserDaoImpl());
		// 		userService.setDetailDao(new DetailDaoImpl());
		// 		System.out.println("老婆在睡觉");
		// 		try {
		// 			Thread.sleep(3 * 1000);
		// 		} catch(Exception e) {

		// 		}
				
		// 		userService.transfer("62203359155560", "62203359168888", 100);
		// 	}
		// }, "妻子").start();

		InputStream is = DateBaseUtil.class.getClassLoader().getResourceAsStream("resources/mybatis-config.xml");
		if (null == is){
			System.out.println("====");
		}

		SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(is);
		SqlSession session = sqlSessionFactory.openSession();
		User userxx = session.selectOne("com.dayuanit.user.queryUser", "62203359168888");
		
		 User user = new User();
		user.username = "tom11";
		user.cardNum = "62220xxxxx11";
		user.balance = 100;

		session.insert("com.dayuanit.user.addUser", user);
		session.commit();


		System.out.println(userxx.cardNum);


	}
}